package ar.com.angrymachine.uitest;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Rectangle;

import ar.com.angrymachine.gameui.ButtonWidget;
import ar.com.angrymachine.gameui.GameCanvas;
import ar.com.angrymachine.gameui.ScrollBarWidget;
import ar.com.angrymachine.gameui.ScrollingContainerWidget;
import ar.com.angrymachine.gameui.Widget;
import ar.com.angrymachine.gameui.ButtonWidget.ButtonListener;

public class UIMainWidget extends Widget implements ButtonListener
{
	private ButtonWidget modal;

	public UIMainWidget(Rectangle area)
	{
		super(null, area);
		
		// create button layout
		modal = new ButtonWidget(this, new Rectangle(0, 0, 80, 30), "Show Dialog", this);
		ScrollBarWidget s = new ScrollBarWidget(this, new Rectangle(60,60,20,300));
		s.setMaximumValue(1800);
		ScrollingContainerWidget c = new ScrollingContainerWidget(this, new Rectangle(200,100,150,300));
		for(int i =0;i!=20;i++)
		{
			new ButtonWidget(c, new Rectangle(0,i*20,50,20), "label "+i, null);
		}
		c.setAreaHeight(100*20);
	}

	public void paint(Graphics g)
	{
		g.setColor(Color.BLACK);
		g.fillRect(0,0,600,600);
	}

	public void onPress(ButtonWidget widget)
	{
		if(widget == modal)
		{
			GameCanvas.screen.showWidgetModal(new UIDialog(this, new Rectangle(10,10,400,400)));
		}
	}
}
